package com.example.onlineeducation.mapper

import com.example.onlineeducation.data.entity.ExamAndTopicEntity
import com.example.onlineeducation.data.json.ExamAndTopicJson
import com.example.onlineeducation.utils.YcTimeUtils
import com.example.onlineeducation.utils.ycToIntNoEmpty
import com.yc.jetpacklib.extension.ycToNoEmpty
import com.yc.jetpacklib.mapper.IMapper
import com.yc.jetpacklib.utils.YcTime
import java.util.*


class ExamAndTopicMapper : IMapper<ExamAndTopicJson, ExamAndTopicEntity> {
    override fun map(input: ExamAndTopicJson): ExamAndTopicEntity = ExamAndTopicEntity(
        input.examJson?.id.ycToNoEmpty(""),
        input.examJson?.examName.ycToNoEmpty(),
        "通过分数：" + input.examJson?.needPoint.ycToNoEmpty(),
        input.examJson?.pass.ycToNoEmpty(),
        input.examJson?.studyTimes.ycToIntNoEmpty(),
        input.examJson?.timeEnd.ycToNoEmpty(),
        YcTimeUtils.compareSmaller(YcTime.dateToString(Date(), YcTime.FORMAT_TIME_SECOND), input.examJson?.timeEnd.ycToNoEmpty()),

        input.topicJson?.id.ycToNoEmpty(""),
        input.topicJson?.topicName.ycToNoEmpty(),
        input.topicJson?.times.ycToIntNoEmpty(),
        input.topicJson?.passNeedTimes.ycToIntNoEmpty(),
        input.topicJson?.pass.ycToNoEmpty()
    )
}

